using Auth.Domain.Entities;

namespace Auth.Infrastructure.Repositories
{
    /// <summary>
    /// 认证仓储接口
    /// </summary>
    /// <typeparam name="T">实体类型</typeparam>
    public interface IAuthRepository<T> where T : BaseEntity
    {
        /// <summary>
        /// 添加实体
        /// </summary>
        /// <param name="entity">要添加的实体</param>
        /// <returns>影响的行数</returns>
        int Create(T entity);

        /// <summary>
        /// 更新实体
        /// </summary>
        /// <param name="entity">要更新的实体</param>
        /// <returns>影响的行数</returns>
        int Update(T entity);

        /// <summary>
        /// 通过ID获取实体
        /// </summary>
        /// <param name="id">实体的唯一标识</param>
        /// <returns>实体对象，如果未找到则返回null</returns>
        T GetById(long id);

        /// <summary>
        /// 获取所有实体
        /// </summary>
        /// <returns>实体列表</returns>
        List<T> GetAll();

        /// <summary>
        /// 根据条件查询实体
        /// </summary>
        /// <param name="whereExpression">查询条件</param>
        /// <returns>实体列表</returns>
        List<T> GetByCondition(Func<T, bool> whereExpression);

        /// <summary>
        /// 通过用户名获取用户
        /// </summary>
        /// <param name="userName">用户名</param>
        /// <returns>用户实体，如果未找到则返回null</returns>
        UserModel GetUserByUserName(string userName);
    }
} 